package com.tuyan.aixiang.model;

public class Result<T> extends BaseEntity {

    public Integer code;

    public T data;
    public String msg;

    // 异常返回字段
    public Integer status;
    public String error;
    public String message;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Optional<T> transform(){
        return new Optional<>(data);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getError() {
        return error;
    }

    public Integer getStatus() {
        return status;
    }

    public boolean isServerError() {
        return null != status;
    }

    public String getServerErrorMessage() {
        return "错误:" + status + ":" + error;
    }

}
